const app = getApp();
var WxParse = require('../../../../wxParse/wxParse.js');
export const handleMixin = {
    async getWxCodeInfo(uniqueId){
        const response = await this.$_server("task/wxacodeInfo", {
            params: {
                uniqueId:  "?uniqueId="+ uniqueId,
            },
        });
        let { data } = response;
        //获取二维码内容
        let code_data = data.data;
        console.log(code_data)
        this.setData({
            "processInstanceId":code_data.processInstId,
            "formId":code_data.formId,
            "model.formId": code_data.formId || "",
            "userId":code_data.userId||"",
            "model.taskId": code_data.taskId || "",
            "type":"share"
        })

        this.initForm();
        // console.log(code_data);
        let user_data = {
            "cityCode":code_data.cityCode,
            "departmentId":code_data.departmentId,
            "governmentId":code_data.governmentId,
            "orgCategoryId":code_data.orgCategoryId
        }

        app.user.userInfo = user_data;

    },
    getRandomId(n = 6) {
        let mm = Math.random();
        let six = 0;
        if (mm > 0.1) {
            six = Math.round(mm * Math.pow(10, n));
        } else {
            mm += 0.1;
            six = Math.round(mm * Math.pow(10, n));
        }
        return +(new Date()) + six.toString();
    },
    //加载富文本
    loadRichHtml(htmlValue){
        var htmlTpl = htmlValue;
        WxParse.wxParse('article', 'html', htmlTpl, this, 5);
    },
    //判断整数
    chk(value) {
        var patrn = /^\d+(\d+)?$/;
        var result = true;
         if(!patrn.test(value)){
            result = false;
         }

        return result;
    },
    //判断小数
    chkd(value) {
        var patrn = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,99})))$/;
        var result = true;
         if(!patrn.test(value)){
            result = false;
         }
        return result;
    },
    onPageScroll(e) {
        try{

            let scrollTop = e.scrollTop;
            // console.log(scrollTop)
            if(scrollTop>40){
                wx.setNavigationBarTitle({ title:this.data.model.name})
            }else{
                wx.setNavigationBarTitle({ title:'数据采集'})
            }

        }catch(e){

        }

    }




}


// {info: {collectorId: "1380476041658761216", processInstId: "adade33b-b3c7-11eb-9f6c-0242ac110005"},…}
// children: {formId: "1392763067015757824",…}
// info: {collectorId: "1380476041658761216", processInstId: "adade33b-b3c7-11eb-9f6c-0242ac110005"}
